//
//  LZFavouriteTableViewCell.m
//  沙哈拉FM
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 S1mpl3. All rights reserved.
//

#import "LZFavouriteTableViewCell.h"
#import "FitHeader.h"
#import "UIImageView+WebCache.h"
@implementation LZFavouriteTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView{
    _createdAtLabel = [[BaseLabel alloc]init];
    _createdAtLabel.textAlignment = 1;
    [self.contentView addSubview:_createdAtLabel];
    
    _coverMiddleImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_coverMiddleImageView];
    
    _tagsLabel = [[BaseLabel alloc]init];
    _tagsLabel.font = [UIFont systemFontOfSize:13];
    _tagsLabel.alpha = .7;
    [self.contentView addSubview:_tagsLabel];
    
    _titleLabel = [[BaseLabel alloc]init];
    _titleLabel.numberOfLines = 0;
    _titleLabel.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_titleLabel];
    
    _tracksCountsLabel = [[BaseLabel alloc]init];
    _tracksCountsLabel.font = [UIFont systemFontOfSize:12];
    _tracksCountsLabel.alpha = .7;
    [self.contentView addSubview:_tracksCountsLabel];
    
    _jishuImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_jishuImageView];
    
}
- (void)layoutSubviews{
    [super layoutSubviews];
    _createdAtLabel.frame = CGRectMake(10 * FITWidth, 0, 30 * FITWidth, 90 * FITHeight);
    _coverMiddleImageView.frame = CGRectMake(_createdAtLabel.frame.origin.x + _createdAtLabel.frame.size.width + 5 * FITWidth, 10 * FITHeight, 70 * FITWidth, 70 * FITHeight);
    _titleLabel.frame = CGRectMake(_coverMiddleImageView.frame.origin.x + _coverMiddleImageView.frame.size.width + 10 * FITWidth, _coverMiddleImageView.frame.origin.y, 250 * FITWidth, 30 * FITHeight);
    _tagsLabel.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height, _titleLabel.frame.size.width - 30 * FITWidth, 15 * FITHeight);
    _jishuImageView.frame = CGRectMake(_tagsLabel.frame.origin.x, _tagsLabel.frame.origin.y + _tagsLabel.frame.size.height + 5 * FITHeight, 16 * FITWidth, 16 * FITHeight);
    _tracksCountsLabel.frame = CGRectMake(_jishuImageView.frame.origin.x + _jishuImageView.frame.size.width + 5 * FITWidth, _jishuImageView.frame.origin.y, _tagsLabel.frame.size.width, _tagsLabel.frame.size.height);
}
- (void)setLzModel:(LZBillboardModel *)lzModel{
    [_coverMiddleImageView sd_setImageWithURL:[NSURL URLWithString:lzModel.coverMiddle] placeholderImage:[UIImage imageNamed:@""]];
    if ([lzModel.isFinished integerValue] == 2) {
        _titleLabel.text = [NSString stringWithFormat:@"%@ (已完结)", lzModel.title];
    }else{
        _titleLabel.text = [NSString stringWithFormat:@"%@", lzModel.title];
    }
    NSString *string = [lzModel.tags stringByReplacingOccurrencesOfString:@"," withString:@" | "];
    _tagsLabel.text = string;
    _jishuImageView.image = [UIImage imageNamed:@"iconfont-jishu"];
    _tracksCountsLabel.text = [NSString stringWithFormat:@"%@ 集", lzModel.tracks];
}
- (void)setLzModel1:(LZBillboardModel *)lzModel1{
    [_coverMiddleImageView sd_setImageWithURL:[NSURL URLWithString:lzModel1.middleLogo] placeholderImage:[UIImage imageNamed:@""]];
    _titleLabel.text = lzModel1.nickname;
    _tagsLabel.text = lzModel1.personDescribe;
    _jishuImageView.image = [UIImage imageNamed:@"iconfont-pengyou"];
    if ([lzModel1.followersCounts integerValue] / 10000 == 0) {
        _tracksCountsLabel.text = [NSString stringWithFormat:@"%@", lzModel1.followersCounts];
    }else{
        _tracksCountsLabel.text = [NSString stringWithFormat:@"%.1f 万", [lzModel1.followersCounts integerValue] / 10000.0];
    }
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
